
<!DOCTYPE html>
<html lang="zh-CN" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Imgui学习 - 浪子之心</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="Blog,"> 
    <meta name="description" content="MrChen Bolg,让控制台消失GetConsoleWindow()&amp;#x2F;&amp;#x2F;获取控制台窗口句柄
SW_HIDE             0SW_SHOWNORMAL       1SW_NORMAL  ,"> 
    <meta name="author" content="Jack Chen"> 
    <link rel="alternative" href="atom.xml" title="浪子之心" type="application/atom+xml"> 
    <link rel="icon" href="/blog/img/favicon.png"> 
    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">

    
<link rel="stylesheet" href="/blog/css/diaspora.css">

<meta name="generator" content="Hexo 5.4.1"><link rel="stylesheet" href="/blog/css/prism.css" type="text/css"></head>

<body class="loading">
    <span id="config-title" style="display:none">浪子之心</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="https://mrchenlearnspace.github.io/blog"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">Imgui学习</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">Imgui学习</h1>
        <div class="stuff">
            <span>四月 12, 2022</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/blog/tags/C/" rel="tag">C++</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/blog/tags/Imgui/" rel="tag">Imgui</a></li></ul>


        </div>
        <div class="content markdown">
            <h1 id="让控制台消失"><a href="#让控制台消失" class="headerlink" title="让控制台消失"></a>让控制台消失</h1><p>GetConsoleWindow()&#x2F;&#x2F;获取控制台窗口句柄</p>
<p>SW_HIDE             0<br>SW_SHOWNORMAL       1<br>SW_NORMAL           1<br>SW_SHOWMINIMIZED    2<br>SW_SHOWMAXIMIZED    3<br>SW_MAXIMIZE         3<br>SW_SHOWNOACTIVATE   4<br>SW_SHOW             5<br>SW_MINIMIZE         6<br>SW_SHOWMINNOACTIVE  7<br>SW_SHOWNA           8<br>SW_RESTORE          9<br>SW_SHOWDEFAULT      10<br>SW_FORCEMINIMIZE    11<br>SW_MAX              11</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;Windows.h&gt;</span></span></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">int</span>, <span class="type">char</span>**)</span></span>&#123;</span><br><span class="line">     <span class="built_in">ShowWindow</span>(<span class="built_in">GetConsoleWindow</span>(), SW_HIDE);</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="导入Imgui"><a href="#导入Imgui" class="headerlink" title="导入Imgui"></a>导入Imgui</h1><p>下载docking的版本有停靠窗口和拿出原窗口的功能</p>
<p>将初始目录下的文件放在解决方案下，将backends和glfw文件夹复制到相应文件夹下。</p>
<p>并将初始目录下的文件放入解决方案的imgui文件夹中</p>
<p>关于平台的backends中的头文件放入头文件夹中</p>
<p>在项目新建main.cpp文件，修改配置</p>
<p><strong>C&#x2F;C++的常规里的附加包含目录</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">.\.</span><br><span class="line">.\glfw\include</span><br><span class="line">.\backends</span><br><span class="line">%(AdditionalIncludeDirectories)<span class="comment">//可不写系统自带</span></span><br></pre></td></tr></table></figure>

<p><strong>链接器常规</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">64</span>架构</span><br><span class="line">.\glfw\lib-vc2010<span class="number">-64</span></span><br><span class="line">%(AdditionalLibraryDirectories)</span><br><span class="line"><span class="number">32</span>架构</span><br><span class="line">.\glfw\lib-vc2010<span class="number">-32</span></span><br><span class="line">%(AdditionalLibraryDirectories)</span><br></pre></td></tr></table></figure>

<p><strong>链接器输入</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">opengl32.lib</span><br><span class="line">glfw3.lib</span><br><span class="line">%(AdditionalDependencies)</span><br></pre></td></tr></table></figure>

<h1 id="导入样例中代码是否报错"><a href="#导入样例中代码是否报错" class="headerlink" title="导入样例中代码是否报错"></a>导入样例中代码是否报错</h1><p>能跑就说明装好了</p>
<h2 id="Global-h"><a href="#Global-h" class="headerlink" title="Global.h"></a>Global.h</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">pragma</span> once</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imgui.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imgui_internal.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imstb_rectpack.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imstb_textedit.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imstb_truetype.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imgui_impl_glfw.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;imgui_impl_opengl3.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br></pre></td></tr></table></figure>

<h2 id="main-cpp"><a href="#main-cpp" class="headerlink" title="main.cpp"></a>main.cpp</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&quot;Global.h&quot;</span></span></span><br><span class="line"><span class="comment">// Dear ImGui: standalone example application for GLFW + OpenGL 3, using programmable pipeline</span></span><br><span class="line"><span class="comment">// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)</span></span><br><span class="line"><span class="comment">// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.</span></span><br><span class="line"><span class="comment">// Read online: https://github.com/ocornut/imgui/tree/master/docs</span></span><br><span class="line"><span class="meta">#<span class="keyword">if</span> defined(IMGUI_IMPL_OPENGL_ES2)</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;GLES2/gl2.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;GLFW/glfw3.h&gt;</span> <span class="comment">// Will drag system OpenGL headers</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.</span></span><br><span class="line"><span class="comment">// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.</span></span><br><span class="line"><span class="comment">// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio.</span></span><br><span class="line"><span class="meta">#<span class="keyword">if</span> defined(_MSC_VER) &amp;&amp; (_MSC_VER &gt;= 1900) &amp;&amp; !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)</span></span><br><span class="line"><span class="meta">#<span class="keyword">pragma</span> comment(lib, <span class="string">&quot;legacy_stdio_definitions&quot;</span>)</span></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">static</span> <span class="type">void</span> <span class="title">glfw_error_callback</span><span class="params">(<span class="type">int</span> error, <span class="type">const</span> <span class="type">char</span>* description)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">fprintf</span>(stderr, <span class="string">&quot;Glfw Error %d: %s\n&quot;</span>, error, description);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">int</span>, <span class="type">char</span>**)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// Setup window</span></span><br><span class="line">    <span class="built_in">glfwSetErrorCallback</span>(glfw_error_callback);</span><br><span class="line">    <span class="keyword">if</span> (!<span class="built_in">glfwInit</span>())</span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Decide GL+GLSL versions</span></span><br><span class="line"><span class="meta">#<span class="keyword">if</span> defined(IMGUI_IMPL_OPENGL_ES2)</span></span><br><span class="line">    <span class="comment">// GL ES 2.0 + GLSL 100</span></span><br><span class="line">    <span class="type">const</span> <span class="type">char</span>* glsl_version = <span class="string">&quot;#version 100&quot;</span>;</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CONTEXT_VERSION_MAJOR, <span class="number">2</span>);</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CONTEXT_VERSION_MINOR, <span class="number">0</span>);</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);</span><br><span class="line"><span class="meta">#<span class="keyword">elif</span> defined(__APPLE__)</span></span><br><span class="line">    <span class="comment">// GL 3.2 + GLSL 150</span></span><br><span class="line">    <span class="type">const</span> <span class="type">char</span>* glsl_version = <span class="string">&quot;#version 150&quot;</span>;</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CONTEXT_VERSION_MAJOR, <span class="number">3</span>);</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CONTEXT_VERSION_MINOR, <span class="number">2</span>);</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);  <span class="comment">// 3.2+ only</span></span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);            <span class="comment">// Required on Mac</span></span><br><span class="line"><span class="meta">#<span class="keyword">else</span></span></span><br><span class="line">    <span class="comment">// GL 3.0 + GLSL 130</span></span><br><span class="line">    <span class="type">const</span> <span class="type">char</span>* glsl_version = <span class="string">&quot;#version 130&quot;</span>;</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CONTEXT_VERSION_MAJOR, <span class="number">3</span>);</span><br><span class="line">    <span class="built_in">glfwWindowHint</span>(GLFW_CONTEXT_VERSION_MINOR, <span class="number">0</span>);</span><br><span class="line">    <span class="comment">//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);  // 3.2+ only</span></span><br><span class="line">    <span class="comment">//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);            // 3.0+ only</span></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// Create window with graphics context</span></span><br><span class="line">    GLFWwindow* window = <span class="built_in">glfwCreateWindow</span>(<span class="number">1280</span>, <span class="number">720</span>, <span class="string">&quot;Dear ImGui GLFW+OpenGL3 example&quot;</span>, <span class="literal">NULL</span>, <span class="literal">NULL</span>);</span><br><span class="line">    <span class="keyword">if</span> (window == <span class="literal">NULL</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line">    <span class="built_in">glfwMakeContextCurrent</span>(window);</span><br><span class="line">    <span class="built_in">glfwSwapInterval</span>(<span class="number">1</span>); <span class="comment">// Enable vsync</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// Setup Dear ImGui context</span></span><br><span class="line">    <span class="built_in">IMGUI_CHECKVERSION</span>();</span><br><span class="line">    ImGui::<span class="built_in">CreateContext</span>();</span><br><span class="line">    ImGuiIO&amp; io = ImGui::<span class="built_in">GetIO</span>(); (<span class="type">void</span>)io;</span><br><span class="line">    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;       <span class="comment">// Enable Keyboard Controls</span></span><br><span class="line">    <span class="comment">//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;      // Enable Gamepad Controls</span></span><br><span class="line">    io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;           <span class="comment">// Enable Docking</span></span><br><span class="line">    io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;         <span class="comment">// Enable Multi-Viewport / Platform Windows</span></span><br><span class="line">    <span class="comment">//io.ConfigViewportsNoAutoMerge = true;</span></span><br><span class="line">    <span class="comment">//io.ConfigViewportsNoTaskBarIcon = true;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// Setup Dear ImGui style</span></span><br><span class="line">    ImGui::<span class="built_in">StyleColorsDark</span>();</span><br><span class="line">    <span class="comment">//ImGui::StyleColorsClassic();</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.</span></span><br><span class="line">    ImGuiStyle&amp; style = ImGui::<span class="built_in">GetStyle</span>();</span><br><span class="line">    <span class="keyword">if</span> (io.ConfigFlags &amp; ImGuiConfigFlags_ViewportsEnable) &#123;</span><br><span class="line">        style.WindowRounding = <span class="number">0.0f</span>;</span><br><span class="line">        style.Colors[ImGuiCol_WindowBg].w = <span class="number">1.0f</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Setup Platform/Renderer backends</span></span><br><span class="line">    <span class="built_in">ImGui_ImplGlfw_InitForOpenGL</span>(window, <span class="literal">true</span>);</span><br><span class="line">    <span class="built_in">ImGui_ImplOpenGL3_Init</span>(glsl_version);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Load Fonts</span></span><br><span class="line">    <span class="comment">// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.</span></span><br><span class="line">    <span class="comment">// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.</span></span><br><span class="line">    <span class="comment">// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).</span></span><br><span class="line">    <span class="comment">// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.</span></span><br><span class="line">    <span class="comment">// - Read &#x27;docs/FONTS.md&#x27; for more instructions and details.</span></span><br><span class="line">    <span class="comment">// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !</span></span><br><span class="line">    <span class="comment">//io.Fonts-&gt;AddFontDefault();</span></span><br><span class="line">    <span class="comment">//io.Fonts-&gt;AddFontFromFileTTF(&quot;../../misc/fonts/Roboto-Medium.ttf&quot;, 16.0f);</span></span><br><span class="line">    <span class="comment">//io.Fonts-&gt;AddFontFromFileTTF(&quot;../../misc/fonts/Cousine-Regular.ttf&quot;, 15.0f);</span></span><br><span class="line">    <span class="comment">//io.Fonts-&gt;AddFontFromFileTTF(&quot;../../misc/fonts/DroidSans.ttf&quot;, 16.0f);</span></span><br><span class="line">    <span class="comment">//io.Fonts-&gt;AddFontFromFileTTF(&quot;../../misc/fonts/ProggyTiny.ttf&quot;, 10.0f);</span></span><br><span class="line">    <span class="comment">//ImFont* font = io.Fonts-&gt;AddFontFromFileTTF(&quot;c:\\Windows\\Fonts\\ArialUni.ttf&quot;, 18.0f, NULL, io.Fonts-&gt;GetGlyphRangesJapanese());</span></span><br><span class="line">    <span class="comment">//IM_ASSERT(font != NULL);</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// Our state</span></span><br><span class="line">    <span class="type">bool</span> show_demo_window = <span class="literal">false</span>;</span><br><span class="line">    <span class="type">bool</span> show_another_window = <span class="literal">false</span>;</span><br><span class="line">    ImVec4 clear_color = <span class="built_in">ImVec4</span>(<span class="number">0.45f</span>, <span class="number">0.55f</span>, <span class="number">0.60f</span>, <span class="number">1.00f</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Main loop</span></span><br><span class="line">    <span class="keyword">while</span> (!<span class="built_in">glfwWindowShouldClose</span>(window)) &#123;</span><br><span class="line">        <span class="comment">// Poll and handle events (inputs, window resize, etc.)</span></span><br><span class="line">        <span class="comment">// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.</span></span><br><span class="line">        <span class="comment">// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.</span></span><br><span class="line">        <span class="comment">// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.</span></span><br><span class="line">        <span class="comment">// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.</span></span><br><span class="line">        <span class="built_in">glfwPollEvents</span>();</span><br><span class="line"></span><br><span class="line">        <span class="comment">// Start the Dear ImGui frame</span></span><br><span class="line">        <span class="built_in">ImGui_ImplOpenGL3_NewFrame</span>();</span><br><span class="line">        <span class="built_in">ImGui_ImplGlfw_NewFrame</span>();</span><br><span class="line">        ImGui::<span class="built_in">NewFrame</span>();</span><br><span class="line">       </span><br><span class="line">        <span class="comment">// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).</span></span><br><span class="line">        <span class="keyword">if</span> (show_demo_window)</span><br><span class="line">            </span><br><span class="line"></span><br><span class="line">        <span class="comment">// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.</span></span><br><span class="line">             ImGui::<span class="built_in">ShowDemoWindow</span>(&amp;show_demo_window);</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="type">static</span> <span class="type">float</span> f = <span class="number">0.0f</span>;</span><br><span class="line">            <span class="type">static</span> <span class="type">int</span> counter = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">            ImGui::<span class="built_in">Begin</span>(<span class="string">&quot;Hello, world!&quot;</span>);                          <span class="comment">// Create a window called &quot;Hello, world!&quot; and append into it.</span></span><br><span class="line"></span><br><span class="line">            ImGui::<span class="built_in">Text</span>(<span class="string">&quot;This is some useful text.&quot;</span>);               <span class="comment">// Display some text (you can use a format strings too)</span></span><br><span class="line">            ImGui::<span class="built_in">Checkbox</span>(<span class="string">&quot;Demo Window&quot;</span>, &amp;show_demo_window);      <span class="comment">// Edit bools storing our window open/close state</span></span><br><span class="line">            ImGui::<span class="built_in">Checkbox</span>(<span class="string">&quot;Another Window&quot;</span>, &amp;show_another_window);</span><br><span class="line"></span><br><span class="line">            ImGui::<span class="built_in">SliderFloat</span>(<span class="string">&quot;float&quot;</span>, &amp;f, <span class="number">0.0f</span>, <span class="number">1.0f</span>);            <span class="comment">// Edit 1 float using a slider from 0.0f to 1.0f</span></span><br><span class="line">            ImGui::<span class="built_in">ColorEdit3</span>(<span class="string">&quot;clear color&quot;</span>, (<span class="type">float</span>*)&amp;clear_color); <span class="comment">// Edit 3 floats representing a color</span></span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span> (ImGui::<span class="built_in">Button</span>(<span class="string">&quot;Button&quot;</span>))                            <span class="comment">// Buttons return true when clicked (most widgets return true when edited/activated)</span></span><br><span class="line">                counter++;</span><br><span class="line">            ImGui::<span class="built_in">SameLine</span>();</span><br><span class="line">            ImGui::<span class="built_in">Text</span>(<span class="string">&quot;counter = %d&quot;</span>, counter);</span><br><span class="line"></span><br><span class="line">            ImGui::<span class="built_in">Text</span>(<span class="string">&quot;Application average %.3f ms/frame (%.1f FPS)&quot;</span>, <span class="number">1000.0f</span> / ImGui::<span class="built_in">GetIO</span>().Framerate, ImGui::<span class="built_in">GetIO</span>().Framerate);</span><br><span class="line">            ImGui::<span class="built_in">End</span>();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 3. Show another simple window.</span></span><br><span class="line">        <span class="keyword">if</span> (show_another_window) &#123;</span><br><span class="line">            ImGui::<span class="built_in">Begin</span>(<span class="string">&quot;Another Window&quot;</span>, &amp;show_another_window);   <span class="comment">// Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)</span></span><br><span class="line">            ImGui::<span class="built_in">Text</span>(<span class="string">&quot;Hello from another window!&quot;</span>);</span><br><span class="line">            <span class="keyword">if</span> (ImGui::<span class="built_in">Button</span>(<span class="string">&quot;Close Me&quot;</span>))</span><br><span class="line">                show_another_window = <span class="literal">false</span>;</span><br><span class="line">            ImGui::<span class="built_in">End</span>();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// Rendering</span></span><br><span class="line">        ImGui::<span class="built_in">Render</span>();</span><br><span class="line">        <span class="type">int</span> display_w, display_h;</span><br><span class="line">        <span class="built_in">glfwGetFramebufferSize</span>(window, &amp;display_w, &amp;display_h);</span><br><span class="line">        <span class="built_in">glViewport</span>(<span class="number">0</span>, <span class="number">0</span>, display_w, display_h);</span><br><span class="line">        <span class="built_in">glClearColor</span>(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);</span><br><span class="line">        <span class="built_in">glClear</span>(GL_COLOR_BUFFER_BIT);</span><br><span class="line">        <span class="built_in">ImGui_ImplOpenGL3_RenderDrawData</span>(ImGui::<span class="built_in">GetDrawData</span>());</span><br><span class="line"></span><br><span class="line">        <span class="comment">// Update and Render additional Platform Windows</span></span><br><span class="line">        <span class="comment">// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.</span></span><br><span class="line">        <span class="comment">//  For this specific demo app we could also call glfwMakeContextCurrent(window) directly)</span></span><br><span class="line">        <span class="keyword">if</span> (io.ConfigFlags &amp; ImGuiConfigFlags_ViewportsEnable) &#123;</span><br><span class="line">            GLFWwindow* backup_current_context = <span class="built_in">glfwGetCurrentContext</span>();</span><br><span class="line">            ImGui::<span class="built_in">UpdatePlatformWindows</span>();</span><br><span class="line">            ImGui::<span class="built_in">RenderPlatformWindowsDefault</span>();</span><br><span class="line">            <span class="built_in">glfwMakeContextCurrent</span>(backup_current_context);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="built_in">glfwSwapBuffers</span>(window);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Cleanup</span></span><br><span class="line">    <span class="built_in">ImGui_ImplOpenGL3_Shutdown</span>();</span><br><span class="line">    <span class="built_in">ImGui_ImplGlfw_Shutdown</span>();</span><br><span class="line">    ImGui::<span class="built_in">DestroyContext</span>();</span><br><span class="line"></span><br><span class="line">    <span class="built_in">glfwDestroyWindow</span>(window);</span><br><span class="line">    <span class="built_in">glfwTerminate</span>();</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="建立窗口"><a href="#建立窗口" class="headerlink" title="建立窗口"></a>建立窗口</h1><p>ImGuiWindowFlags参数可直接用加法叠加效果</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">ImGuiWindowFlags_None          = <span class="number">0</span>,</span><br><span class="line">ImGuiWindowFlags_NoTitleBar    = <span class="number">1</span> &lt;&lt; <span class="number">0</span>,   <span class="comment">// 禁用标题栏</span></span><br><span class="line">ImGuiWindowFlags_NoResize      = <span class="number">1</span> &lt;&lt; <span class="number">1</span>,   <span class="comment">// 使用右下角手柄禁用用户调整大小</span></span><br><span class="line">ImGuiWindowFlags_NoMove        = <span class="number">1</span> &lt;&lt; <span class="number">2</span>,   <span class="comment">// 禁止用户移动窗口</span></span><br><span class="line">ImGuiWindowFlags_NoCollapse    = <span class="number">1</span> &lt;&lt; <span class="number">5</span>,   <span class="comment">// 禁用用户折叠窗口双击它。也被称为窗口菜单按钮(例如在停靠节点内)  </span></span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">if (isOpen) &#123;</span><br><span class="line">          ImGui::Begin(&quot;my&quot;, &amp;isOpen, ImGuiWindowFlags_None);</span><br><span class="line">          ImGui::End();</span><br><span class="line">      &#125;</span><br></pre></td></tr></table></figure>

<h1 id="按钮"><a href="#按钮" class="headerlink" title="按钮"></a>按钮</h1><p>放入begin和end中</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (isOpen) &#123;</span><br><span class="line">          ImGui::<span class="built_in">Begin</span>(<span class="string">&quot;my&quot;</span>, &amp;isOpen, ImGuiWindowFlags_None);</span><br><span class="line">          <span class="keyword">if</span> (ImGui::<span class="built_in">Button</span>(<span class="string">&quot;asd1&quot;</span>)) &#123;</span><br><span class="line">              <span class="built_in">printf</span>(<span class="string">&quot;dsads&quot;</span>);<span class="comment">//按下</span></span><br><span class="line">          &#125;</span><br><span class="line">          ImGui::<span class="built_in">End</span>();</span><br><span class="line">      &#125;</span><br></pre></td></tr></table></figure>

<p>按钮不换行</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ImGui::<span class="built_in">Button</span>(<span class="string">&quot;asd1&quot;</span>);</span><br><span class="line">         ImGui::<span class="built_in">SameLine</span>();</span><br><span class="line">         ImGui::<span class="built_in">Button</span>(<span class="string">&quot;asd1&quot;</span>);</span><br></pre></td></tr></table></figure>

<h1 id="单选框和复选框"><a href="#单选框和复选框" class="headerlink" title="单选框和复选框"></a>单选框和复选框</h1><h2 id="单选框"><a href="#单选框" class="headerlink" title="单选框"></a>单选框</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;01&quot;</span>, &amp;num, <span class="number">1</span>);</span><br><span class="line">ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;02&quot;</span>, &amp;num, <span class="number">2</span>);</span><br><span class="line">ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;03&quot;</span>, &amp;num, <span class="number">3</span>);</span><br><span class="line">ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;04&quot;</span>, &amp;inta, intb);<span class="comment">//如果选到这一栏&amp;a=b</span></span><br></pre></td></tr></table></figure>

<h2 id="复选框"><a href="#复选框" class="headerlink" title="复选框"></a>复选框</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ImGui::<span class="built_in">Checkbox</span>(<span class="string">&quot;03&quot;</span>, &amp;isOpen);</span><br><span class="line">ImGui::<span class="built_in">Checkbox</span>(<span class="string">&quot;03&quot;</span>, &amp;<span class="type">bool</span>);</span><br></pre></td></tr></table></figure>



<h1 id="折叠框"><a href="#折叠框" class="headerlink" title="折叠框"></a>折叠框</h1><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (ImGui::<span class="built_in">CollapsingHeader</span>(<span class="string">&quot;CollapsingHeader1&quot;</span> )) &#123;</span><br><span class="line">    ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;01&quot;</span>, &amp;num, <span class="number">1</span>);</span><br><span class="line">    ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;02&quot;</span>, &amp;num, <span class="number">2</span>);</span><br><span class="line">    ImGui::<span class="built_in">RadioButton</span>(<span class="string">&quot;03&quot;</span>, &amp;num, <span class="number">3</span>);</span><br><span class="line">    ImGui::<span class="built_in">Checkbox</span>(<span class="string">&quot;03&quot;</span>, &amp;isOpen);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h1 id="文本框"><a href="#文本框" class="headerlink" title="文本框"></a>文本框</h1><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ImGui::<span class="built_in">Text</span>(<span class="string">&quot;dsadsa&quot;</span>,<span class="string">&quot;tyt&quot;</span>);<span class="comment">//最简单的</span></span><br><span class="line">ImGui::<span class="built_in">BulletText</span>(<span class="string">&quot;BulletText&quot;</span>);<span class="comment">//带点的</span></span><br></pre></td></tr></table></figure>

<p>HelpMarker</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="type">static</span> <span class="type">void</span> <span class="title">HelpMarker</span><span class="params">(<span class="type">const</span> <span class="type">char</span>* desc)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    ImGui::<span class="built_in">TextDisabled</span>(<span class="string">&quot;(?)&quot;</span>);</span><br><span class="line">    <span class="keyword">if</span> (ImGui::<span class="built_in">IsItemHovered</span>())</span><br><span class="line">    &#123;</span><br><span class="line">        ImGui::<span class="built_in">BeginTooltip</span>();</span><br><span class="line">        ImGui::<span class="built_in">PushTextWrapPos</span>(ImGui::<span class="built_in">GetFontSize</span>() * <span class="number">35.0f</span>);</span><br><span class="line">        ImGui::<span class="built_in">TextUnformatted</span>(desc);</span><br><span class="line">        ImGui::<span class="built_in">PopTextWrapPos</span>();</span><br><span class="line">        ImGui::<span class="built_in">EndTooltip</span>();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="滑块条"><a href="#滑块条" class="headerlink" title="滑块条"></a>滑块条</h1><p>name不能一样</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">ImGui::<span class="built_in">SliderFloat</span>(<span class="string">&quot;float&quot;</span>, &amp;f, <span class="number">0.0f</span>, <span class="number">1.0f</span>); </span><br><span class="line">ImGui::<span class="built_in">SliderInt</span>(<span class="string">&quot;SliderInt&quot;</span>, &amp;i, <span class="number">0</span>, <span class="number">100</span>);    </span><br><span class="line">ImGui::<span class="built_in">SliderFloat</span>(<span class="string">&quot;float&quot;</span>, &amp;<span class="type">float</span>, min, max);    </span><br><span class="line">ImGui::<span class="built_in">SliderInt</span>(<span class="string">&quot;SliderInt&quot;</span>, &amp;<span class="type">int</span>, min, max); </span><br></pre></td></tr></table></figure>

<h1 id="切换中文"><a href="#切换中文" class="headerlink" title="切换中文"></a>切换中文</h1><p>c:\Windows\Fonts\选一款字体，GetGlyphRangesChineseFull（）换成这个。在字符前面加u8</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ImFont* font = io.Fonts-&gt;<span class="built_in">AddFontFromFileTTF</span>(<span class="string">&quot;c:\\Windows\\Fonts\\simkai.ttf&quot;</span>, <span class="number">18.0f</span>, <span class="literal">NULL</span>, io.Fonts-&gt;<span class="built_in">GetGlyphRangesChineseFull</span>());</span><br><span class="line">    <span class="built_in">IM_ASSERT</span>(font != <span class="literal">NULL</span>);</span><br><span class="line">ImGui::<span class="built_in">CollapsingHeader</span>(<span class="string">u8&quot;集合 CollapsingHeader1&quot;</span> );</span><br></pre></td></tr></table></figure>

<p>方法二</p>
<p>通过binary_to_compressed_c.cpp转化为数组然后建立一个头文件复制进去</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ImFont* font = io.Fonts-&gt;<span class="built_in">AddFontFromMemoryTTF</span>((<span class="type">void</span>*)font_h_data,font_h_size, <span class="number">18.0f</span>,<span class="literal">NULL</span>, io.Fonts-&gt;<span class="built_in">GetGlyphRangesChineseFull</span>());</span><br><span class="line">ImGui::<span class="built_in">CollapsingHeader</span>(<span class="string">u8&quot;集合 CollapsingHeader1&quot;</span> );</span><br></pre></td></tr></table></figure>

<h1 id="切换控件颜色"><a href="#切换控件颜色" class="headerlink" title="切换控件颜色"></a>切换控件颜色</h1><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">style.Colors[ImGuiCol_TitleBgCollapsed] = <span class="built_in">ImColor</span>(<span class="number">180</span>, <span class="number">180</span>, <span class="number">180</span>);</span><br><span class="line">style.Colors[ImGuiCol_枚举类型] = <span class="built_in">ImColor</span>(<span class="number">180</span>, <span class="number">180</span>, <span class="number">180</span>);</span><br></pre></td></tr></table></figure>




            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="/music/jucilang.mp3">
            </audio>
            
        </div>
        
    <div id='gitalk-container' class="comment link"
		data-enable='true'
        data-ae='true'
        data-ci='99f95a936c6fcdb1bd67'
        data-cs='c2d1bba3d6b7f9ade4f3de09a63925bd837c25ea'
        data-r='mrchenlearnspace.github.io'
        data-o='MrChenLearnSpace'
        data-a='MrChenLearnSpace'
        data-d='false'
    >查看评论</div>


    </div>
    
        <div class='side'>
			<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E8%AE%A9%E6%8E%A7%E5%88%B6%E5%8F%B0%E6%B6%88%E5%A4%B1"><span class="toc-number">1.</span> <span class="toc-text">让控制台消失</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%BC%E5%85%A5Imgui"><span class="toc-number">2.</span> <span class="toc-text">导入Imgui</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%BC%E5%85%A5%E6%A0%B7%E4%BE%8B%E4%B8%AD%E4%BB%A3%E7%A0%81%E6%98%AF%E5%90%A6%E6%8A%A5%E9%94%99"><span class="toc-number">3.</span> <span class="toc-text">导入样例中代码是否报错</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Global-h"><span class="toc-number">3.1.</span> <span class="toc-text">Global.h</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#main-cpp"><span class="toc-number">3.2.</span> <span class="toc-text">main.cpp</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%BB%BA%E7%AB%8B%E7%AA%97%E5%8F%A3"><span class="toc-number">4.</span> <span class="toc-text">建立窗口</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%8C%89%E9%92%AE"><span class="toc-number">5.</span> <span class="toc-text">按钮</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8D%95%E9%80%89%E6%A1%86%E5%92%8C%E5%A4%8D%E9%80%89%E6%A1%86"><span class="toc-number">6.</span> <span class="toc-text">单选框和复选框</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8D%95%E9%80%89%E6%A1%86"><span class="toc-number">6.1.</span> <span class="toc-text">单选框</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%8D%E9%80%89%E6%A1%86"><span class="toc-number">6.2.</span> <span class="toc-text">复选框</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%8A%98%E5%8F%A0%E6%A1%86"><span class="toc-number">7.</span> <span class="toc-text">折叠框</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%96%87%E6%9C%AC%E6%A1%86"><span class="toc-number">8.</span> <span class="toc-text">文本框</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%BB%91%E5%9D%97%E6%9D%A1"><span class="toc-number">9.</span> <span class="toc-text">滑块条</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%88%87%E6%8D%A2%E4%B8%AD%E6%96%87"><span class="toc-number">10.</span> <span class="toc-text">切换中文</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%88%87%E6%8D%A2%E6%8E%A7%E4%BB%B6%E9%A2%9C%E8%89%B2"><span class="toc-number">11.</span> <span class="toc-text">切换控件颜色</span></a></li></ol>	
        </div>
    
</div>


    </div>
</div>
</body>

<script src="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/blog/js/plugin.js"></script>
<script src="/blog/js/typed.js"></script>
<script src="/blog/js/diaspora.js"></script>


<link rel="stylesheet" href="/blog/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/blog/photoswipe/default-skin/default-skin.css">


<script src="/blog/photoswipe/photoswipe.min.js"></script>
<script src="/blog/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>



<script type="text/x-mathjax-config">
    MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno",skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']},
        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },
        messageStyle: "none"
    });
</script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>



<!-- Google Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YMJ8CBH8F7"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-YMJ8CBH8F7');
</script>
<!-- End Google Analytics -->


</html>
